﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SAM3D
{
    class MeshObject : TransformableDrawableGameComponent
    {
        private readonly Model _mesh;
        private ICameraService _cameraProvider;
        public MeshObject(Game game, Transform transform, Model mesh) : base(game, transform)
        {
            _mesh = mesh;
            _cameraProvider = ((ICameraService) Game.Services.GetService(typeof (ICameraService)));
        }

        public override void Draw(GameTime time)
        {
            var camera = _cameraProvider.GetCamera();
            _mesh.Draw(Transform, camera.View, camera.Projection);
            base.Draw(time);

        }
    }
}